package app;

import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.*;

public class AboutScreen extends Canvas {

    private Display display;
    private Displayable next;
    private Timer timer;
    private int dismissTime;
    private Image image;

    public AboutScreen(Display display, Displayable next, int dismissTime, Image image) {
        timer = new Timer();
        this.display = display;
        this.next = next;
        this.dismissTime = dismissTime;
        this.image = image;
        setFullScreenMode(true);
        display.setCurrent(this);
    }

    private void dismiss() {
        timer.cancel();
        display.setCurrent(next);
    }

    protected void keyPressed(int keyCode) {
        dismiss();
    }


    protected void paint(Graphics g) {
        g.setColor(0x000000);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);
    }

    protected void pointerPressed(int x, int y) {
        dismiss();
    }

    protected void showNotify() {
        if (dismissTime > 0) {
            timer.schedule(new TimerTask() {

                public void run() {
                    dismiss();
                }
            }, dismissTime);

        }
    }
}
